package demo.java;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import demo.util.JsonReadUtils;
import org.junit.Test;

import java.util.Map;

/**
 * @author wangly on @date 2023/2/1
 */
public class tempChange {
    @Test
    public void test2(){
        int a = (int)Math.ceil(599/100);
        System.out.println(a);
    }
    @Test
    public void test1(){
        Map<String,String> nameMap = Maps.newHashMap();
        extracted(JsonReadUtils.readObject("temp/diagnosisInfoDTO.json"), nameMap);
        extracted(JsonReadUtils.readObject("temp/operationInfoDTO.json"), nameMap);
        extracted(JsonReadUtils.readObject("temp/patientOrderDTO.json"), nameMap);
        System.out.println(JSON.toJSONString(nameMap));
    }

    private static void extracted(JSONObject jsonObject, Map<String, String> nameMap) {
        for (Map.Entry<String, Object> stringObjectEntry : jsonObject.entrySet()) {
            String key = stringObjectEntry.getKey();
            String value = ((JSONObject)stringObjectEntry.getValue()).getString("description");
            if(value!=null){
                nameMap.put(key,value);
            }
        }
    }
}
